import React, { Component } from 'react';
import {
    Text,
    View,
    StyleSheet,
    RefreshControl,
    TouchableOpacity,
    DeviceEventEmitter,
    AsyncStorage,
} from 'react-native';
import NavigationBar from '../components/NavigationBar';
import { Actions } from 'react-native-router-flux';
import Session from '../utils/SessionUtils';

export default class initPage extends Component {

    constructor(props) {
        super(props);
        console.log('initpage:'+props.store);
    }

    componentDidMount() {

        // setTimeout(()=>{
        //     if(Session && Session.Token){
        //         Actions.tabbar();
        //     }else{
        //         // Actions.login();
        //         Actions.replace('login');
        //     }
        // }, 1000);
        AsyncStorage.clear()
        AsyncStorage.getItem('userToken').then(token => {
            if(token != null){
                Session.Token = token
           
                Actions.tabbar()
            }else{
                Actions.replace('login');
            }
            
        })
        // AsyncStorage.getItem('token', (error, result) => {
        //     if (!error) {
        //         try {
        //             if(!result){
                        
        //                 return;
        //             }
        //             if(result==='true'){
                        
        //             }else{
        //                 Actions.login();
        //             }
        //         } catch (e) {
        //             Actions.login();
        //         }
        //     } else {
        //         reject(error);
        //     }
        // });
    }

    componentWillUnmount() {

    }


    render() {



        return (
            <View style={styles.container}>
                <Text>mine</Text>
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
    },
})